package com.milk.controller.admin;

import com.milk.dto.CommonPageQueryDTO;
import com.milk.entity.Orders;
import com.milk.result.PageResult;
import com.milk.result.Result;
import com.milk.service.IOrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("/adminOrderController")
@RequestMapping("/admin/order")
@Slf4j
@CrossOrigin
public class OrderController {
    @Autowired
    private IOrdersService ordersService;

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @GetMapping("/pageQuery")
    public Result<PageResult> pageQuery(CommonPageQueryDTO dto){
        log.info("分页查询 = {}",dto);
        PageResult pageResult = ordersService.pageQuery(dto);
        return Result.success(pageResult);
    }

    /**
     * 修改状态
     * @param orders
     * @return
     */
    @PostMapping("/update")
    public Result updateStatus(@RequestBody Orders orders){
        ordersService.upddateStatus(orders);
        return Result.success();
    }
}
